"railroad maintenance worker," 1918, American English slang, of unknown origin; dancer perhaps from movements required in the work of tamping down ties or pumping a hand-cart, gandy perhaps from the name of a machinery belt company in Baltimore, Maryland.
[origin unknown; a 1935 source says that the third sense was ''mentioned by George Borrow in his descriptions of early nineteenth-century street fairs'']